/*
 * SdlSurfacePtr.h
 *
 *  Created on: 2014年4月27日
 *      Author: zhengchuanjiang
 */

#ifndef SDLSURFACEPTR_H_
#define SDLSURFACEPTR_H_

#include <SDL.h>

namespace sdl
{

class SurfacePtr
{
public:
    SurfacePtr();
    ~SurfacePtr();

    explicit SurfacePtr(SDL_Surface* surface);

    SDL_Surface* get() const;

    void reset();

    void reset(SDL_Surface* surface);

    operator  bool() const;

    SDL_Texture* update(SDL_Renderer* render);

    SDL_Texture* getTexture();

    bool getSize(int& w, int& h);

private:
    SurfacePtr(const SurfacePtr& other);
    const SurfacePtr& operator = (const SurfacePtr& other);

protected:
    void cleanup();

    void cleanTexture();

protected:
    SDL_Surface*    m_surface;
    SDL_Texture*    m_texture;
    SDL_Renderer*   m_render;

};



} /* namespace sdl */

#endif /* SDLSURFACEPTR_H_ */
